A beautiful report

Quarto demo for the DVIZ course

Author

Teresa Kubacka

Published

April 24, 2023

Abstract
This document summarizes the basic functionalities of typesetting with Quarto

TESTypesetting with Jupyter and Quarto

TEST

For documentation, see: Quarto User Guide and Reference.

In the command line:

Use:

quarto preview notebookname.ipynb

to live-preview the document.

Use:

quarto render notebookname.ipynb --to html 

to render the html.

Front-matter

  • execute: should all the cells be executed upon rendering
  • code-fold: all code shown in folded cells
  • echo: disable code render
  • self-contained: all the images are embedded in the html
  • toc: enable table of contents; the levels can be further specified
  • theme: one of the Bootswatch themes. A customized css file can also be specified.

Code

We can have collapsible code snippets

Click here to see the chart styling
species_styles = {
    'Adelie': {'color': 'tomato', 's': 100, 'alpha': 0.5}, 
    'Chinstrap': {'color': 'dodgerblue', 'marker': 'v'}, 
    'Gentoo': {'color': 'darkgray', 'edgecolor':'black'}
}

I can hide some code cells:

And some other code cells I can show:

data_agg = data.groupby(['species','island','sex'])['body_mass_g'].count().rename('count').reset_index()
data_agg2 = data_agg.groupby('species')['count'].sum().reset_index()

Printing tables

Below is a simple table:

Table 1: This is a table with aggregated data.
species count
0 Adelie 146
1 Chinstrap 68
2 Gentoo 119

We can change the width of the cell where the table output is rendered:

Table 2: This is a sample of a long table
species island bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex
0 Adelie Torgersen 39.1 18.7 181.0 3750.0 Male
1 Adelie Torgersen 39.5 17.4 186.0 3800.0 Female
2 Adelie Torgersen 40.3 18.0 195.0 3250.0 Female
3 Adelie Torgersen NaN NaN NaN NaN NaN
4 Adelie Torgersen 36.7 19.3 193.0 3450.0 Female

Both tables can be referenced and are rendered to links: Table 1 and Table 2

Plotly figures

Let’s make a plotly chart. This will be Figure 1.

Figure 1: The figure illustrates how many penguins in each species were measured.

Matplotlib

Figure 2: Penguin sizes per species.

Other fancy things

Embedding images

That’s what we did last week

Embedding iframes and arbitrary html content

Figure 3: Iframe.

Notes and warnings

We can have various types of notes:

This is a note that can be expanded

You can change the callout to:

  • .callout-note
  • .callout-tip
  • .callout-important
  • .callout-caution
  • .callout-warning

With collapse flag you toggle the collapse behavior. You can switch the icon on and off using the icon flag. You can set these parameters per cell of in front matter globally.

Writing on margins

We can write on the margins:

Figure 4: Body mass per species.

This is sucha a nice seaborn chart with pastel colors

We can also print a table in the main field and insert a chart on the margin:

Figure 5: Penguin count statistics.

species island sex count
0 Adelie Biscoe Female 22
1 Adelie Biscoe Male 22
2 Adelie Dream Female 27
3 Adelie Dream Male 28
4 Adelie Torgersen Female 24
5 Adelie Torgersen Male 23
6 Chinstrap Dream Female 34
7 Chinstrap Dream Male 34
8 Gentoo Biscoe Female 58
9 Gentoo Biscoe Male 61

I can also add asides. Adding more text for this cell to be longer. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text. More text that has a different color

This is a span that has the class aside which places it in the margin without a footnote number.

Citing bibliography

We can also cite bibliography. Use a reference manager like Zotero or Jabref to generate a .bib file with citations. You can also create the entries by hand - they are following a BibTex format. You can also use a tool like https://www.bibme.org/bibtex to generate an entry in the .bib file following an URL.

Citing the penguins (Allisonhorst 2020)

(TK 2021)

The end.

References

Allisonhorst. 2020. “Allisonhorst/Palmerpenguins: A Great Intro Dataset for Data Exploration & Visualization (Alternative to Iris).” GitHub. https://github.com/allisonhorst/palmerpenguins.
TK. 2021. “New Entry.”